<?php
// 将数组转换成查询字符串
function arr2str($arr){
    $str='';
    foreach($arr as $key=>$val){
        $str.=$key.'="'.$val.'",';
    }
    return substr($str,0,-1);
}
// 将相对路径处理成绝对路径
function path($target){
    if(is_string($target)){
        if(substr($target,0,4)==='http'){
            return $target;
        }
        $target='http://'.$_SERVER['HTTP_HOST'].$target;
    }
    return $target;
}
// 获取所有请求头: nginx下直接调用getallheaders会报错
if (!function_exists('getallheaders'))
{
    function getallheaders()
    {
           $headers = [];
       foreach ($_SERVER as $name => $value)
       {
           if (substr($name, 0, 5) == 'HTTP_')
           {
               $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
           }
       }
       return $headers;
    }
}
?>